/*
 * Copyright (c)  2020,  DataPipeline
 * All rights reserved.
 *
 * Id:ConnectionSource.java   2020-07-18 17:16
 */
package cn.datacare.orm.connection;

import java.sql.Connection;
import java.util.List;

/**
 * <p>
 * Title:
 * </p>
 * <p>
 * Description:
 * </p>
 * <p>
 * Copyright: Copyright (c) 2020
 * </p>
 * <p>
 * Company/Department: DataPipeline
 * </p>
 *
 * @author wanglijun
 * @version 1.0
 * @since 2020-07-18 17:16
 */
public interface ConnectionSource {
    /**
     * 得到一个主库链接,用于序列,medata等
     * @return Connection
     */
    Connection getMaster();


    /**
     * 获取Salve
     * @return Connection
     */
    Connection getSlave();

    /***
     * 获取Metadata
     * @return Connection
     */
    Connection getMetaData();


    /**
     * 根据条件得到链接
     *
     * @param sqlId
     * @param isUpdate 是否更新数据
     * @param sql sql
     * @param params Params
     * @return Connection  Connection
     */
    Connection getConn(String sqlId, boolean isUpdate, String sql, List<?> params);

    /**
     * 强迫选择主从，取消掉，没人用
     * @param isMaster  是否Master
     */
    @Deprecated
    void forceBegin(boolean isMaster);

    /**
     * 强制选择主从结束，如果调用了forceBegin，则必须调用forceEnd
     */
    @Deprecated
    void forceEnd();

    /**
     * 是否事务
     * @return boolean
     */
    boolean isTransaction();
}
